<template>
 <div class="employRoster-search-table">
    <el-table
      :data="tableDatas_com"
      border
      max-height='500'
      style="width: 100%">
    <el-table-column
      v-for='(k,i) in tableOptionSelect'
      :label='k.label'
      :prop='k.value'
      :width='k.width || handleTitleWidth(k.label.length)'
      align='center'
      >
    </el-table-column>

  </el-table>
 </div>
</template>

<script>


export default {
  props: {
    tableOptionSelect: {
      default: []
    },
    tableDatas: {
      default: []
    }
  },
  computed: {
 
    tableDatas_com () {
      this.tableDatas.forEach((ele, index, arr) => {

        if (ele.start_dt_chn.split(' ').length == 2) {
          ele.start_dt_chn = ele.start_dt_chn.split(' ')[0]
        }

        if (ele.org_inst_srv_dt.split(' ').length == 2) {
          ele.org_inst_srv_dt = ele.org_inst_srv_dt.split(' ')[0]
        }
        if (ele.cmpny_seniority_dt.split(' ').length == 2) { ele.cmpny_seniority_dt = ele.cmpny_seniority_dt.split(' ')[0] }
        if (ele.service_dt.split(' ').length == 2) { ele.service_dt = ele.service_dt.split(' ')[0] }
        if (ele.seniority_pay_dt.split(' ').length == 2) { ele.seniority_pay_dt = ele.seniority_pay_dt.split(' ')[0] }
        if (ele.probation_dt.split(' ').length == 2) { ele.probation_dt = ele.probation_dt.split(' ')[0] }
        if (ele.termination_dt.split(' ').length == 2) { ele.termination_dt = ele.termination_dt.split(' ')[0] }
        if (ele.birthdate.split(' ').length == 2) { ele.birthdate = ele.birthdate.split(' ')[0] }
        if (ele.c_demob_dt.split(' ').length == 2) { ele.c_demob_dt = ele.c_demob_dt.split(' ')[0] }
        if (ele.political_effdt.split(' ').length == 2) { ele.political_effdt = ele.political_effdt.split(' ')[0] }
        if (ele.dt_issued.split(' ').length == 2) { ele.dt_issued = ele.dt_issued.split(' ')[0] }
        if (ele.visa_dt.split(' ').length == 2) { ele.visa_dt = ele.visa_dt.split(' ')[0] }
        if (ele.c_visa_issue_dt.split(' ').length == 2) { ele.c_visa_issue_dt = ele.c_visa_issue_dt.split(' ')[0] }

      })

      return this.tableDatas
    }
  },
  data () {
    return {

    }
  },
  mounted () {
  },

  methods: {
    handleTitleWidth (len) {
      if (len < 4) {
        return 80
      } else if (len >= 4 && len <= 6) {
        return len * 30
      } else if (len > 6) {
        return len * 20
      }
    }
  },

}
</script>

<style scoped lang='less'>
.employRoster-search-table {
  padding: 15px 15px 30px 15px;
}
</style>